package com.qf.service.Impl;

import com.qf.dto.ResultCode;
import com.qf.exceptions.AddDataException;
import com.qf.mapper.AuthorsMapper;
import com.qf.pojo.Authors;
import com.qf.service.AuthorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class AuthorsServiceImpl implements AuthorsService {
    private AuthorsMapper authorsMapper;
     @Autowired
    public void setAuthorsMapper(AuthorsMapper authorsMapper) {
        this.authorsMapper = authorsMapper;
    }

    @Override
    public void insertAuthors(Authors authors) {
        if (authors == null || authors.getAuthorname()==null) {
            //数据不符合我们的要求,返回结果,中断操作,抛出异常
            throw new AddDataException("数据不能为空", ResultCode.NULL_DATA);
        }
         authorsMapper.insertAuthors(authors);

    }
}
